//
//  InformationTableViewCell.m
//  NewProject
//
//  Created by admin on 2017/6/16.
//  Copyright © 2017年 李航飞. All rights reserved.
//

#import "InformationTableViewCell.h"
@interface InformationTableViewCell()
@property(nonatomic,strong)UILabel *titleLabel;
@property(nonatomic,strong)UIButton *rightButton;
@property(nonatomic,strong)UIImageView *headImageView;
@property(nonatomic,strong)UIImageView *rightImageView;
@property(nonatomic,strong)UILabel *contentLabel;
@property(nonatomic,strong)UIView *lineView;
@end

@implementation InformationTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        
        if ([reuseIdentifier isEqualToString:@"4"]){
            self.contentView.backgroundColor = RGB0X(0xF8F9F6);
        }else{
            _lineView = [[UIView alloc]init];
            _lineView.backgroundColor = RGB0X(0xF8F9F6);
            [self.contentView addSubview:_lineView];

            _titleLabel = [[UILabel alloc]init];
            _titleLabel.textColor = RGB0X(0x333333);
            _titleLabel.font = FONT(14);
            [self.contentView addSubview:_titleLabel];

            _rightImageView = [[UIImageView alloc]init];
            _rightImageView.image = [UIImage imageNamed:@"箭头"];
            [self.contentView addSubview:_rightImageView];

            _contentLabel = [[UILabel alloc]init];
            _contentLabel.font = FONT(14);
            [self.contentView addSubview:_contentLabel];
            
            if([reuseIdentifier isEqualToString:@"0"]){
                _headImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"头像"]];
                _headImageView.tag = 333;
                [self.contentView addSubview:_headImageView];
                [self createFirstConstraint];
            }else{
                _contentLabel = [[UILabel alloc]init];
                _contentLabel.font = FONT(14);
                [self.contentView addSubview:_contentLabel];
                [self createSecondConstraint];
                
                if ([reuseIdentifier integerValue]<5) {
                    _contentLabel.textColor = RGB0X(0xC8C8C8);
                }else{
                    _contentLabel.textColor = RGB0X(0xFFD603);
                }
            }
        }
    }
    return self;
}

- (void)createFirstConstraint{
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(15/WIDTH_6_SCALE);
        make.centerY.equalTo(self.contentView.mas_centerY).offset(0);
    }];
    [_headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).offset(-37/WIDTH_6_SCALE);
        make.centerY.equalTo(self.contentView.mas_centerY).offset(0);
        make.size.mas_equalTo(CGSizeMake(35/WIDTH_6_SCALE,35/WIDTH_6_SCALE));
    }];
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(0/WIDTH_6_SCALE);
        make.right.equalTo(self.contentView.mas_right).offset(0/WIDTH_6_SCALE);
        make.top.equalTo(self.contentView.mas_bottom).offset(0);
        make.height.mas_equalTo(1/WIDTH_6_SCALE);
    }];
    [_rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).offset(-15/WIDTH_6_SCALE);
        make.centerY.equalTo(self.contentView.mas_centerY).offset(0);
    }];
}

- (void)createSecondConstraint{
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(15/WIDTH_6_SCALE);
        make.centerY.equalTo(self.contentView.mas_centerY).offset(0);
    }];
    [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).offset(-37/WIDTH_6_SCALE);
        make.centerY.equalTo(self.contentView.mas_centerY).offset(0);
    }];
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(15/WIDTH_6_SCALE);
        make.right.equalTo(self.contentView.mas_right).offset(-15/WIDTH_6_SCALE);
        make.top.equalTo(self.contentView.mas_bottom).offset(0);
        make.height.mas_equalTo(1/WIDTH_6_SCALE);
    }];
    [_rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).offset(-15/WIDTH_6_SCALE);
        make.centerY.equalTo(self.contentView.mas_centerY).offset(0);
    }];
}

- (void)setModel:(NSDictionary *)model{
    _titleLabel.text = model[kTitle];
    _contentLabel.text = model[kContent];

}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
